package com.husk.leetcode.dp;

/**
 * <p>
 * <p>
 * https://leetcode-cn.com/problemset/all/?search=jump
 *
 * </p>
 *
 * @author hushunke@sm.vvip-u.com
 * @since 2021/3/30
 */
public class JumpModel {

    /**
     * 55. 跳跃游戏
     * <p>
     * https://leetcode-cn.com/problems/jump-game/
     * <p>
     *
     * @param nums
     * @return
     */
    public boolean canJump(int[] nums) {
        boolean[] dp = new boolean[nums.length];
        dp[0] = true;
        for (int i = 1; i < nums.length; i++) {
            for (int j = 0; j < i; j++) {
                if (dp[j] && j + nums[j] >= i) {
                    dp[i] = true;
                    break;
                }
            }
        }
        return dp[nums.length - 1];
    }

    /**
     * 45. 跳跃游戏 II
     * <p>
     * https://leetcode-cn.com/problems/jump-game-ii/
     * <p>
     *
     * @param nums
     * @return
     */
    public int jump(int[] nums) {
        // TODO


        return 0;
    }


}
